import QtQuick 1.0
import "models"
import "templates"
//import "js/main.js" as MainManager

Rectangle {
    id: settingsScreen
    color: "#00FFFFFF";
    Image {
        id: formBkg
        source: "images/backgrounds/app_bkg_360x640.png"
    }
    RadioField{
        id: som
        y:10
        labelText: "Choose your system of measurement"
        width: parent.width
        Component.onCompleted: {
            console.log(settingsScreen.height);
            if(mainContainer.var_metric.toLowerCase()=="metric"){
                selectedBtnID = somMetric;
                somUS.state = ""
            }else{
                selectedBtnID = somUS;
                somMetric.state = ""
            }
            selectedBtnID.state = "isSelected"
        }
    }
/*
    Rectangle{
        id: currencyField
        y: 110;
        anchors {
            left: parent.left;
            right: parent.right;
        }
        height: currencyList.height + 30

        /** Amount Field Label ** /
        Label{
            y: 0
            id: currencyLabel
            labelText: "Currency"
            anchors {
                left: parent.left; leftMargin: 20;
                right: parent.right; rightMargin: 10;
            }
            width: parent.width;
        }

        /** Currency DropDown ** /
        ChoiceList{
            id: currencyList
            y: 30;
            width: parent.width
            anchors{
                left: parent.left; leftMargin: 10;
                right: parent.right; rightMargin: 10;
            }
            height: 50
            collapsedHeight: 50;
            expandedHeight: 300;
            listModel: CurrencyItemsModel {}
            listDelegate: CurrencyListItem {}
            Component.onCompleted: {
                for(var i = 0; i < currencyList.listModel.count; i++) {
                    if(currencyList.listModel.get(i).currencyShortName == mainContainer.item_measuring_unit){
                        currencyList.itemsList.currentIndex = i;
                        currencyList.selectedID = ""
                        break;
                    }
                }
            }
        }
    }
*/

    Rectangle {
        id: footerButtonsConainer
        width: parent.width
/*
        anchors {
            //right: parent.right; rightMargin: 10
            //right: parent.right; rightMargin: 10
            //bottom: mainContainer.bottom;
        }*/
        y: 430;

        Button {
            buttonText: "Save"
            buttonWidth: 120
            anchors{
                left: parent.left; leftMargin: 10;
            }

            onActivated: {
                console.log("selected metric id: " + som.selectedBtnID.buttonText);
                mainContainer.getManager().saveSettings(som.selectedBtnID.buttonText, mainContainer.var_currency, mainContainer.shoppingItemListModel, mainContainer.listIdMain);
                mainContainer.var_metric = som.selectedBtnID.buttonText
                mainContainer.state = "shoppingListsState"
            }
        }

        Button {
            buttonText: "Cancel"
            buttonWidth: 120
            anchors{
                right: parent.right; rightMargin: 10;
            }

            onActivated: {
                mainContainer.state = "shoppingListsState"
            }
        }
    }

    Rectangle {
        id: about

        anchors.left: parent.left; anchors.right: parent.right
        anchors.leftMargin: 10
        anchors.rightMargin: 10
        y: 500
        Column {
            Text {
                id: version
                text: "ShoppingList, version 1.0"
                font.family: nokiaStandard.name
                font.pixelSize: 14
                font.weight: Font.Light
                color: "#969696"
            }
            Text {
                id: copyright
                text: "Copyright ClujUITeam, 2011"
                font.family: nokiaStandard.name
                font.pixelSize: 14
                font.weight: Font.Light
                color: "#969696"
            }
        }
    }

/*

    Component.onCompleted: {
        //mainContainer.screenID = settingsScreen
        //mainContainer.getManager().loadSettingsData();
    }*/
}
